package com.nx.project.javacore.factory;

import com.nx.project.javacore.factory.impl.Dumplins;
import com.nx.project.javacore.factory.impl.Egg;
import com.nx.project.javacore.factory.impl.Milk;
import com.nx.project.javacore.factory.impl.Noodle;

/**
 * 简单工厂设计模式
 */
public class BreakfastFactory01 {

    public Breakfast create(String id){
        if (id==null){
            throw  new RuntimeException("name is null");
        }

        if ("Dumplins".equals(id)){
            return new Dumplins();
        }

        if ("Milk".equals(id)){
            return new Milk();
        }

        if ("Noodle".equals(id)){
            return new Noodle();
        }

        if ("Egg".equals(id)){
            return new Egg();
        }
        throw  new RuntimeException("unkoow breakfast name "+id);
    }
}
